package thread;
/**
 * 中断线程
 */
public class SleepDemo2 {
    public static void main(String[] args) {
        Thread wkj =new Thread("wkj"){//给线程取名
            public void  run(){
                System.out.println(getName()+"累了睡一会儿");
                try {
                    Thread.sleep(10000000);
                } catch (InterruptedException e) {
                    System.out.println("谁呀");
                    //e.printStackTrace();//输出异常原因
                }
                System.out.println(getName()+"醒了");
            }
        };
        Thread fcq =new Thread("fcq"){
          public void run(){
              System.out.println(getName()+"中午去哪吃饭");
              try {
                  Thread.sleep(3000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              System.out.println(getName()+"问问克晶吧");
              wkj.interrupt();//中断睡眠，触发wkj线程的InterruptrdException异常
          }
        };
        wkj.start();
        fcq.start();

    }
}
